// commons.js
// 参考源码: https://github.com/Yangkeloff/Node.js-practice-LookHe/blob/master/models/optfile.js
// 
var fs = require('fs');
function readFile(path, funcRecall){
    // resp.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
    fs.readFile(path, function(err, data){
        if(err){
            console.log(err);
        }else{
            console.log( data.toString() );
            funcRecall( data );
        }
    });
}

module.exports = {
    readFile: readFile,
    readImg: function(path, resp){
        fs.readFile(path, 'binary', function(err, data){
            if(err){
                console.log(err);
                return;
            }else{
                resp.write(data, 'binary');
                resp.end();
            }
        });
    }
};